package de.g18.scavengerhunt.activity;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.view.KeyEvent;
import android.widget.TextView;
import de.g18.scavengerhunt.AppApplicationContext;
import de.g18.scavengerhunt.R;
import de.g18.scavengerhunt.utils.GameUtils;

/**
 * Layout for the 'about' screen
 */
public class AboutActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);

        TextView txtAbout = (TextView) findViewById(R.id.txtAbout);
        txtAbout.setText(Html.fromHtml(getString(R.string.privacy)));
        txtAbout.setMovementMethod(new ScrollingMovementMethod());
    }

    /**
     * Called automatically when the Activity has been created and will be visible to the user.
     */
    @Override
    protected void onStart() {
        super.onStart();

        // Give the ApplicationContext the current activity instance.
        AppApplicationContext.setActivity(this);
    }

    /**
     * This override makes sure, that the device back button only intents to load the MainMenuActivity.
     */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            GameUtils.showActivity(new MainMenuActivity());
            return false;
        }

        return super.onKeyDown(keyCode, event);
    }
}
